<template>
  <div class="nav-header">
    <el-icon class="fold-menu" @click="handleFoldClick">
      <component :is="isFold ? 'expand' : 'fold'"></component>
    </el-icon>
    <div class="content">
      <hy-breadcrumb :breadcrumbs="breadcrumbs" />
      <user-info></user-info>
    </div>
  </div>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import UserInfo from './user-info.vue'
import { HyBreadcrumb } from '@/base-ui/breadcrumb'
import { useStore } from 'vuex'
import { useRoute } from 'vue-router'
import { pathMapBreadcrumbs } from '@/utils/map-menus'
const store = useStore()
const route = useRoute()
const breadcrumbs = computed(() => {
  const userMenus = store.state.login.userMenus
  const path = route.path
  const breadcrumbs = pathMapBreadcrumbs(userMenus, path)
  return breadcrumbs
})
const isFold = ref(false)
const emit = defineEmits(['foldChange'])
const handleFoldClick = () => {
  isFold.value = !isFold.value
  emit('foldChange', isFold.value)
}
defineExpose({ isFold, handleFoldClick })
</script>
<style lang="less" scoped>
.nav-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
}
</style>
